<template>
	<view class="popularcard-content" :style="height?`height:${height};`:''" @click="goanswerdetails(carddata.id)">
		<!-- 卡片上部分 -->
		<view class="popularcard-content-header">
			<view class="content-header-left">
				<img :src="carddata.avatar?.url" alt="" class="header-left-img" v-if="carddata.avatar">
				<img :src="queryImage('modelone1')" alt="" class="header-left-img" v-else>
			</view>
			<view class="content-header-right">
				<view class="header-right-top">
					<span class="right-top-title">{{carddata.nickname}}</span>
					<img :src="queryImage('cardlogo1')" alt="" class="right-top-img">
					<span class="right-top-text">关注&nbsp;{{carddata.user_interest?.length}}</span>
					<span class="right-top-text1">粉丝&nbsp;{{carddata.user_fans?.length}}</span>
				</view>
				<view class="header-right-bttom">
					<span class="right-bttom-title">
						专业标签:&nbsp;
					</span>
					<view class="right-bttom-right">
						<span class="bttom-right-text" v-for="(item,index) in carddata.tag_list"
							:key="item">{{item.label}}</span>
					</view>
				</view>
			</view>
		</view>
		<!-- 卡片中间 -->
		<view class="popularcard-content-midel">
			<span class="content-midel-text">{{carddata.profile}}</span>
		</view>
		<!-- 卡片评分部分 -->
		<view class="popularcard-content-score">
			<span class="content-score-title">回答评分:&nbsp;</span>
			<uni-rate :readonly="true" :size="18"
				:value="carddata?.article_comment_score_aggregate?.aggregate?.avg?.score" :allowHalf="true" />
			<span
				class="content-score-text">{{carddata?.article_comment_score_aggregate?.aggregate?.avg?.score || 0}}</span>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		name: "showCard",
		props: {
			carddata: {
				type: Object,
				default: () => {}
			},
			height: {
				type: String
			}
		},
		data() {
			return {
				stri: ''
			};
		},
		computed: {
			...mapState({
				headericon: state => state.remote?.headericon?.data_list ?? []
			})
		},
		methods: {
			queryImage(label, key = "headericon") {
				return this[key]?.find(res => res?.label == label)?.img?.url;
			},
			goanswerdetails(id) {
				uni.navigateTo({
					url: `/pages_a/answerdetails/answerdetails?id=${id}`
				})
			},
			goquestion() {
				this.stri = JSON.stringify(this.carddata)
				// console.log("接收的数据", this.stri);
				getApp().val = this.stri
				uni.switchTab({
					url: `/pages/question/question`
				})
			}
		}
	}
</script>

<style lang="scss">
	.popularcard-content {
		width: 100%;
		// height: 410rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 3rpx 8rpx 0rpx rgba(0, 0, 0, 0.16);
		border-radius: 15rpx 15rpx 15rpx 15rpx;
		opacity: 1;
		box-sizing: border-box;
		padding: 20rpx;
		margin-bottom: 40rpx;

		.popularcard-content-header {
			width: 100%;
			display: flex;
			align-items: flex-start;

			.content-header-left {
				display: flex;
				justify-content: center;
				align-items: center;
				width: 120rpx;
				height: 120rpx;
				border: 1rpx solid #CCCCCC;
				border-radius: 50%;
				overflow: hidden;
				margin-right: 25rpx;

				.header-left-img {
					width: 100%;
					height: 100%;
				}
			}

			.content-header-right {
				flex: 1;
				font-size: 24rpx;
				font-family: Alibaba PuHuiTi 2.0-55 Regular, Alibaba PuHuiTi 20;
				font-weight: 400;
				color: #999999;
				line-height: 40rpx;

				.header-right-top {

					display: flex;
					align-items: center;

					.right-top-title {
						font-size: 32rpx;
						font-family: Source Han Sans CN-Bold, Source Han Sans CN;
						font-weight: 700;
						color: #3D3D3D;
						line-height: 42rpx;
						max-width: 220rpx;
					}

					.right-top-img {
						width: 30rpx;
						height: 30rpx;
						margin-left: 17rpx;
						margin-right: 40rpx;
					}

					.right-top-text {
						margin-right: 20rpx;
					}

					.right-top-text1 {
						margin-right: 0;
					}
				}

				.header-right-bttom {
					margin-top: 18rpx;
					display: flex;

					.right-bttom-title {
						margin-right: 20rpx;
					}

					.right-bttom-right {
						flex: 1;
						box-sizing: border-box;

						.bttom-right-text {
							font-size: 24rpx;
							font-family: Source Han Sans CN-Medium, Source Han Sans CN;
							font-weight: 500;
							color: #F09500;
							line-height: 35rpx;
							border-bottom: 2rpx solid #F09500;
							margin-right: 15rpx;
						}

						.bttom-right-text:last-child {
							margin-right: 0;
						}
					}
				}

			}
		}

		.popularcard-content-midel {
			width: 95%;
			margin-top: 10rpx;

			.content-midel-text {
				width: 100%;
				display: inline-block;
				font-size: 30rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #999999;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				line-height: 43rpx;
			}
		}

		.popularcard-content-score {
			width: 100%;
			font-size: 24rpx;
			font-family: Source Han Sans CN-Medium, Source Han Sans CN;
			font-weight: 500;
			color: #5F5F5F;
			line-height: 35rpx;
			display: flex;
			align-items: flex-end;

			.content-score-title {
				font-size: 24rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #999999;
				line-height: 35rpx;
				margin-right: 25rpx;
			}

			.content-score-text {
				margin-left: 10rpx;
			}
		}

		.popularcard-content-bottom {
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: flex-end;
			margin-top: 20rpx;

			.content-bottom-left {
				.bottom-left-text {
					display: inline-block;
					box-sizing: border-box;
					padding: 0 15rpx;
					background-color: #FFE6B8;

					border-radius: 10rpx 10rpx 10rpx 10rpx;
					font-size: 24rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #F09500;
					line-height: 40rpx;
					margin-right: 20rpx;
				}

				.bottom-right-text {
					display: inline-block;
					box-sizing: border-box;
					padding: 0 15rpx;
					background-color: #EEEEEE;
					border-radius: 10rpx 10rpx 10rpx 10rpx;
					font-size: 24rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #5F5F5F;
					line-height: 40rpx;
					margin-right: 20rpx;
				}
			}

			.content-bottom-rightbtn {
				text-align: center;
				width: 200rpx;
				height: 60rpx;
				background: #F09500;
				border-radius: 50rpx 50rpx 50rpx 50rpx;
				font-size: 30rpx;
				font-family: Source Han Sans CN-Bold, Source Han Sans CN;
				font-weight: 700;
				color: #FFFFFF;
				line-height: 60rpx;
			}
		}
	}
</style>